<input type="hidden" name="<?=$this->fieldName;?>[upload]" value="1">
<div id="<?php echo $this->fieldId;  ?>_current" class="mediaListUpload">
	<?php
	echo $this->GetThumbnailBlock($this->data['file'], $this->fieldName, isset($this->params['showimgtumb']) ? $this->params['showimgtumb'] : false);
	?>
</div>
<?php
if ($this->params['editable'])
{
?>
<?=$this->Style()->IncludeStyleFile(array('css' => array('fileuploader')));?>
<?=$this->Style()->IncludeStyleFile(array('js' => array('fileuploader')));?>
<div id="<?php echo $this->fieldId;  ?>"></div>
<script type="text/javascript">
$(document).ready(function(){

	var file = $('#<?php echo $this->fieldId;  ?>');
	var messageBlock = file.closest('.block-field').find('.form-error-message');
    var uploader = new qq.FileUploader({
        element: file[0],
        action: file.closest('form').attr('action'),
        params: {
            ajax: true,
            upload: true,
            fieldName: "<?=$this->fieldName;?>[file]"
        },
        onSubmit: function(id, fileName){
        	messageBlock.html('');
        },
        onProgress: function(id, fileName, loaded, total){},
        onComplete: function(id, fileName, responseJSON){
            if (responseJSON && responseJSON.html)
            {
				$('#<?php echo $this->fieldId;  ?>_current').html(responseJSON.html);
            }

            file.find('.qq-upload-list li:eq('+(id)+')').hide();
        },
        onCancel: function(id, fileName){
        	file.find('.qq-upload-list li:eq('+(id)+')').hide();
		},
        multiple: false,
        showMessage: function(message){
			messageBlock.html(message);
		},
        template: '<div class="qq-uploader">' +
	        '<div class="qq-upload-drop-area"><span><?php echo Mozg_Lang::_('Drop files here to upload'); ?></span></div>' +
	        '<div class="qq-upload-button action_button"><span><?php echo Mozg_Lang::_('Upload a file'); ?></span></div>' +
	        '<ul class="qq-upload-list"></ul>' +
	     '</div>',
        fileTemplate: '<li>' +
	        '<span class="qq-upload-file"></span>' +
	        '<span class="qq-upload-spinner"></span>' +
	        '<span class="qq-upload-size"></span>' +
	        '<a class="qq-upload-cancel" href="#"><?php echo Mozg_Lang::_('Cancel'); ?></a>' +
	        '<span class="qq-upload-failed-text"><?php echo Mozg_Lang::_('Failed'); ?></span>' +
	    '</li>'
    });

	$('#<?php echo $this->fieldId;  ?>_current a.del').live('click', function(e){
		e.preventDefault();
		$(this).parent().remove();
	});
});
</script>
<?php
}